package com.huawei.appgallery.wishwall.ui.fragment;

import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import com.huawei.appgallery.foundation.ui.framework.widget.BounceViewPager;
import com.huawei.appgallery.wishbase.ui.fragment.BaseWishFragment;
import com.huawei.appgallery.wishwall.api.IWishWallDeleteActivityResult;
import com.huawei.appgallery.wishwall.api.IWishWallFragmentProtocol;
import com.huawei.appgallery.wishwall.ui.fragment.protocol.WishWallFragmentProtocol;
import com.huawei.appgallery.wishwall.widget.WishColumnNavigator;
import com.huawei.hmf.annotation.FragmentDefine;
import com.huawei.secure.android.common.intent.SafeBroadcastReceiver;
import java.lang.ref.WeakReference;
import java.util.List;
import o.azb;
import o.ddq.d;
import o.ddq.f;
import o.ddu;
import o.ddx;
import o.dec;
import o.ded;
import o.dgp;
import o.ContentManager;
import o.fho;
import o.fiu;
import o.fjb;
import o.fjc;
import o.fjm;
import o.ll;

@FragmentDefine(alias = "wishwall.fragment", protocol = WishWallFragmentProtocol.class)
public class WishWallFragment extends BaseWishFragment {
    private a ʼ;
    private fjm ˊ = fjm.ॱ(this);
    private ddx ˋ;
    private WishColumnNavigator ˎ;
    private BounceViewPager ˏ;
    private List<dgp> ॱ;
    private boolean ᐝ = false;

    final class a extends SafeBroadcastReceiver {
        final /* synthetic */ WishWallFragment ˋ;

        private a(WishWallFragment wishWallFragment) {
            this.ˋ = wishWallFragment;
        }

        public void onReceiveMsg(Context context, Intent intent) {
            String action = intent.getAction();
            if (action != null && action.contentEquals("action_online_brd_refresh_list")) {
                this.ˋ.ʽᐝ();
            }
        }
    }

    static class c implements ded {
        private WeakReference<WishWallFragment> ˊ;

        c(WishWallFragment wishWallFragment) {
            this.ˊ = new WeakReference(wishWallFragment);
        }

        public void ॱ(boolean z) {
            if (this.ˊ != null) {
                WishWallFragment wishWallFragment = (WishWallFragment) this.ˊ.get();
                if (wishWallFragment != null) {
                    wishWallFragment.ᐝ = z;
                    if (wishWallFragment.ॱ() != null) {
                        wishWallFragment.ॱ().ˊ(wishWallFragment, z);
                    }
                }
            }
        }
    }

    public void ˏ(Bundle bundle) {
        super.ˏ(bundle);
        this.ʼ = new a();
        ʿॱ();
    }

    public View ˋ(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        super.ˋ(layoutInflater, viewGroup, bundle);
        ViewGroup viewGroup2 = (ViewGroup) layoutInflater.inflate(o.ddq.c.ˊॱ, viewGroup, false);
        this.ˎ = (WishColumnNavigator) viewGroup2.findViewById(d.ॱʻ);
        azb.ˏ(this.ˎ);
        this.ˏ = (BounceViewPager) viewGroup2.findViewById(d.ʼᐝ);
        this.ˏ.setIsCanScroll(false);
        this.ˎ.setViewPager(this.ˏ);
        IWishWallFragmentProtocol iWishWallFragmentProtocol = (IWishWallFragmentProtocol) this.ˊ.ॱ();
        if (iWishWallFragmentProtocol != null) {
            this.ॱ = iWishWallFragmentProtocol.getColumnNavigatorList();
            if (!this.ॱ.isEmpty()) {
                this.ˎ.ˏ(this.ॱ);
                this.ˋ = new ddx(ॱˋ(), ʽॱ(), this.ॱ);
                this.ˋ.ˏ(new c(this));
                this.ˏ.setAdapter(this.ˋ);
                this.ˏ.setOffscreenPageLimit(this.ॱ.size() - 1);
                if (bundle == null) {
                    this.ˎ.setCurrentItem(0);
                } else {
                    this.ˎ.setCurrentItem(bundle.getInt("wishwall_tab_index"));
                }
            }
        }
        return viewGroup2;
    }

    public void ˋ(@NonNull Bundle bundle) {
        bundle.putInt("wishwall_tab_index", this.ˎ.ˎ());
        super.ˋ(bundle);
    }

    public void ʾॱ() {
        super.ʾॱ();
        if (!this.ॱ.isEmpty()) {
            for (dgp o_dgp : this.ॱ) {
                if (o_dgp.ˊ().contentEquals(ॱ(f.ʻॱ))) {
                    this.ˎ.setCurrentItem(o_dgp);
                    return;
                }
            }
        }
    }

    public void ʼᐝ() {
        super.ʼᐝ();
        fjb ˎ = fho.ˏ().ˋ("WishWall").ˎ("wish.wall.delete.activity");
        ˎ.ˊ();
        fiu.ˊ().ॱ(ॱˊ(), ˎ, new fjc<IWishWallDeleteActivityResult>(this) {
            final /* synthetic */ WishWallFragment ˏ;

            {
                this.ˏ = r1;
            }

            public /* synthetic */ void ˎ(int i, Object obj) {
                ॱ(i, (IWishWallDeleteActivityResult) obj);
            }

            public void ॱ(int i, IWishWallDeleteActivityResult iWishWallDeleteActivityResult) {
                ddu.ˊ.ˋ("TaskFragment", "WishWallDeleteActivity result:" + i);
                if (i == -1 && iWishWallDeleteActivityResult != null && iWishWallDeleteActivityResult.getHasDeleted()) {
                    this.ˏ.ʽᐝ();
                }
            }
        });
    }

    public void ˋ(int i) {
        if (ॱ() != null) {
            ॱ().ˊ(this, this.ᐝ);
        }
    }

    public void ˎˎ() {
        super.ˎˎ();
        ˈॱ();
    }

    private void ʽᐝ() {
        for (int i = 0; i < this.ˋ.getCount(); i++) {
            Fragment ॱ = this.ˋ.ॱ(i);
            if (ॱ instanceof dec) {
                ((dec) ॱ).ˊʻ();
            }
        }
    }

    private void ʿॱ() {
        IntentFilter intentFilter = new IntentFilter();
        intentFilter.addAction("action_online_brd_refresh_list");
        ll.ˏ(ContentManager.getInstant().getContext()).ˏ(this.ʼ, intentFilter);
    }

    private void ˈॱ() {
        if (this.ʼ != null) {
            ll.ˏ(ContentManager.getInstant().getContext()).ˋ(this.ʼ);
        }
    }
}
